perm filename VRP.MSG[TIM,LSP] blob
sn#619507 filedate 1981-10-19 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 Bum!
C00006 ENDMK
C⊗;
Bum!
Vaughn:
Here is my bummed version of TAK. It takes 184 milliseconds on SAIL.
There are many bums here and I'll explain them so that you can bum
the 68000 version. I expect on stack intensive stuff and 16 bit arithmetic
that the 68000 at 8mhz is 1 mips or 1/3 a KL. SCORE is 20% faster, but
is down so I cannot time it right now.
It is embedded in Lisp for historic reasons.
(lap tak subr)
(jrst 0 time) ;Timing routine which just calls TAK1
tak1
(caig a 0 b) ;a ≤ b
(popj p) ;result in c (a is reg 1, b 2, c 3)
tak2 ;internal entry point
(add fxp (% 0 0 5 5)) ;2 spare stack slots plus 3 argument slots
(124←33 a -2 fxp) ;dmovem a,b onto stack (losing ncomplr)
(movem c 0 fxp) ;c onto stack
(movei a -1 a) ;subtract 1 from a using indexing hardware
(caile a 0 b) ;save a pushj, popj b assumed ≤ 18 bits to use
;indexing hardware here too
(pushj p tak2)
(movem c -3 fxp) ;save result
(120←33 a -1 fxp) ;dmove y,z into regs
(move c -2 fxp) ;x
(movei a -1 a) ;y-1
(caile a 0 b) ;save pushj, popj by doing the compare here
(pushj p tak2)
(movem c -4 fxp) ;result on stack
(move a 0 fxp) ;z into a
(120←33 b -2 fxp) ;dmove x,y into regs
(movei a -1 a) ;z-1
(caile a 0 b) ;done?
(pushj p tak2)
(120←33 a -4 fxp) ;results into a,b, c has 3rd call already
(sub fxp (% 0 0 5 5)) ;pop stack (assume no underflow)
(caig a 0 b) ;flush tail recursive call
(popj p) ;done!
(jrst 0 tak2) ;tail recursion
;;; Timing
time
(move tt me) ;location with my job number
(calli tt 23.) ;runtim UUO
(movem tt tim1) ;save answer
(movei a 18.) ;load up args
(movei b 12.)
(movei c 6.)
(pushj p tak1) ;do it
(move tt me)
(calli tt 23.) ;runtim UUO
(sub tt tim1) ;subtract
(jrst 0 fix1) ;fixnum!
me (0)
tim1 (0)
()